package com.efamily.ewallet.client.expense.bean;

import java.io.Serializable;
import java.util.List;

import com.extjs.gxt.ui.client.data.BeanModelTag;

public class ExpenseCategoryBean implements BeanModelTag, Serializable {

	private int id = -1;

	private String name;

	private List<ExpenseTypeBean> types;

	public ExpenseCategoryBean() {
	}

	public ExpenseCategoryBean(String name) {
		setName(name);
	}

	public ExpenseCategoryBean(int id, String name, List<ExpenseTypeBean> types) {
		this.id = id;
		this.name = name;
		this.types = types;
	}

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public List<ExpenseTypeBean> getTypes() {
		return types;
	}

	public void setTypes(List<ExpenseTypeBean> types) {
		this.types = types;
	}

	@Override
	public String toString() {
		return getName();
	}

	@Override
	public int hashCode() {
		if (id == -1) {
			return super.hashCode();
		} else {
			return id;
		}
	}

	@Override
	public boolean equals(Object obj) {
		if (!(obj instanceof ExpenseCategoryBean)) {
			return false;
		} else if (((ExpenseCategoryBean) obj).getId() == -1
				&& this.getId() == -1 && (obj != this)) {
			return false;
		} else if (((ExpenseCategoryBean) obj).getId() != this.getId()) {
			return false;
		}
		return true;
	}

}
